package com.stx.blog.action;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.stx.blog.service.ArticleService;
import com.stx.blog.service.UserService;
import com.stx.blog.vo.ArticleVo;
import com.stx.blog.vo.FriendVo;
import com.stx.blog.vo.UserVo;

public class FriendAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private UserVo uv;
	private List<UserVo> userList;
	private ArticleVo av;
	private List<ArticleVo> articleList;
	private FriendVo fv;
	private UserService us;
	private ArticleService as;
	
	
	public UserService getUs() {
		return us;
	}
	public void setUs(UserService us) {
		this.us = us;
	}
	public ArticleService getAs() {
		return as;
	}
	public void setAs(ArticleService as) {
		this.as = as;
	}
	public UserVo getUv() {
		return uv;
	}
	public void setUv(UserVo uv) {
		this.uv = uv;
	}
	public List<UserVo> getUserList() {
		return userList;
	}
	public void setUserList(List<UserVo> userList) {
		this.userList = userList;
	}
	public ArticleVo getAv() {
		return av;
	}
	public void setAv(ArticleVo av) {
		this.av = av;
	}
	public List<ArticleVo> getArticleList() {
		return articleList;
	}
	public void setArticleList(List<ArticleVo> articleList) {
		this.articleList = articleList;
	}
	public FriendVo getFv() {
		return fv;
	}
	public void setFv(FriendVo fv) {
		this.fv = fv;
	}
	
	public String findFriend(){
		uv=us.getUsesr(uv.getBuid());
		userList=us.getList(uv);
		System.out.println(userList.get(0).getBlogName());
		return "find";
	}
	
	//跳转此action传进来buid
	public String showFriend(){
		uv=(UserVo) ServletActionContext.getRequest().getSession().getAttribute("user");
		uv=us.getUsesr(uv.getBuid());
		userList=us.getFriendsList(uv);
		return "showok";
		
	}
	//添加好友要两个id
	public String addFriend(){
		uv=(UserVo) ServletActionContext.getRequest().getSession().getAttribute("user");
		us.addFriend(uv.getBuid(),fv.getFrinendid());
		return "addok";
	}
}
